/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dawnland02.model.task.impl;

import dawnland02.data.map.model.MatrixDirection;
import dawnland02.model.action.Action;
import dawnland02.model.action.ActionType;
import dawnland02.model.entity.EntityInternal;
import dawnland02.model.task.BaseTask;
import dawnland02.model.task.GroupTask;
import dawnland02.model.task.Task;
import dawnland02.model.task.TaskStatus;

/**
 * @author Petru Obreja (obrejap@yahoo.com)
 */
public class BuildRoadToDestinationTask extends GroupTask{

    private Integer destinationMatrixCellId;

    public BuildRoadToDestinationTask(EntityInternal entity, Integer destinationMatrixCellId) {
        super("BuildRoadToDestinationTask", entity);
        this.destinationMatrixCellId = destinationMatrixCellId;
        init();
    }

    @Override
    protected void init(){MoveToTask moveToTask = new MoveToTask(entity, destinationMatrixCellId);

        for(Task subTask: moveToTask.getTasks()){
            GroupTask groupTask = new GroupTask(entity);
            BuildRoadTask buildRoadTask = new BuildRoadTask(entity);
            groupTask.addTask(buildRoadTask);
            groupTask.addTask(subTask);

            addTask(groupTask);
        }
        setTaskStatus(TaskStatus.INITIALISED);
    }

    @Override
    protected void prepare() {
        //nothing more to be done
        this.setTaskStatus(TaskStatus.PREPARED);
    }

}
